#include<stdio.h>
#include<string.h>

using namespace std;

int main() 
{
   char string[16], hex[16];
   char values[] = "ABCDEF";
   int i, j, size; 
   long dec, res, a;
   
   scanf("%s", string);
   while(string[0] != '-') {
      if(string[1] != 'x') {
         sscanf(string, "%d", &dec);
         res = dec;
         i = 0;
         while(res != 0)
         {
            a = res % 16;
            hex[i++] = (a>9)?values[a-10] : a+'0';
            res /= 16;
         }
         hex[i] = '\0';
         printf("0x");
         for(j=i-1; j>=0; j--)
            printf("%c", hex[j]);
         printf("\n");
      }
      else {
         dec = 0;
         for(j=2; j<strlen(string); j++)
             dec = dec*16 + ((string[j] < 'A')?string[j]-'0':10 + string[j] - 'A');
         printf("%d\n", dec);
      }
      scanf("%s", string);
   }   
   return 0;
}
